curl --request POST \
--url https://omni-api.sendblue.com/admin/keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "Message sender",
"role": "messaging"
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: 'Message sender', role: 'messaging'})
};
fetch('https://omni-api.sendblue.com/admin/keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://omni-api.sendblue.com/admin/keys"
payload = {
"name": "Message sender",
"role": "messaging"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"name": "<string>",
"permissions": [
"accounts:create"
],
"role": "standard",
"created_by": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"id": "<string>",
"name": "<string>",
"permissions": [
"accounts:create"
],
"role": "standard",
"created_by": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"secret": "<string>"
}{
"error": {
"code": "invalid_request",
"message": "Unknown field",
"details": {
"field": "colour"
}
}
}Create an API key. Its `secret` is shown once, here.
Requires keys:manage. A creator may delegate only permissions they
hold. A delegated key inherits the issuing key’s expiry unless the
request gives it an earlier one. Only an administrator session or
account token may issue a Standard key with access to the compatible
API under /t. Authenticate with Authorization: Bearer <id>.<secret>.
An identical retry returns the existing key metadata. The secret is
displayed on the first successful creation only. Replaying the same
request after revocation returns 404 not_found and creates no key.
Required permission: keys:manage. Accepted credentials: a signed-in administrator, an API key, the account token.
curl --request POST \
--url https://omni-api.sendblue.com/admin/keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "Message sender",
"role": "messaging"
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: 'Message sender', role: 'messaging'})
};
fetch('https://omni-api.sendblue.com/admin/keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://omni-api.sendblue.com/admin/keys"
payload = {
"name": "Message sender",
"role": "messaging"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"name": "<string>",
"permissions": [
"accounts:create"
],
"role": "standard",
"created_by": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"id": "<string>",
"name": "<string>",
"permissions": [
"accounts:create"
],
"role": "standard",
"created_by": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"secret": "<string>"
}{
"error": {
"code": "invalid_request",
"message": "Unknown field",
"details": {
"field": "colour"
}
}
}Authorizations
Headers
Body
Optional. An absent body is an empty object.
Omitting both role and permissions requests a Standard key. With a role and an explicit list, every listed permission must belong to the role. Only the explicit permissions are granted. A key with explicit grants uses the native API only, except when both the standard role and its exact unchanged permission set were requested. accounts:create, subaccounts:manage, team:manage, team:read and webhooks:receive cannot be delegated to a key.
standard preserves the historical Standard key grants.
read_only grants the read operations in the Standard bundle.
messaging grants me:read, messages:read and messages:send.
billing_read grants me:read and billing:read (balance).
standard, read_only, messaging, billing_read accounts:create, billing:history, billing:read, billing:refill, billing:top_up, brands:read, brands:write, calls:create, calls:read, calls:write, campaigns:read, campaigns:write, company_settings:read, contacts:read, contacts:write, keys:manage, me:read, media:read, media:write, messages:read, messages:send, messages:write, number_orders:cancel, number_orders:create, number_orders:read, numbers:purchase, numbers:read, numbers:release, numbers:write, operations:read, prices:read, recordings:read, recordings:write, settings:read, settings:write, subaccounts:manage, tags:read, tags:write, team:manage, team:read, variables:read, variables:write, webhooks:manage, webhooks:receive, workflows:read, workflows:write Response
Matching issuance replay. The original key metadata excludes its secret.
Effective permission names in lexical order. Grants are immutable after issuance.
accounts:create, billing:history, billing:read, billing:refill, billing:top_up, brands:read, brands:write, calls:create, calls:read, calls:write, campaigns:read, campaigns:write, company_settings:read, contacts:read, contacts:write, keys:manage, me:read, media:read, media:write, messages:read, messages:send, messages:write, number_orders:cancel, number_orders:create, number_orders:read, numbers:purchase, numbers:read, numbers:release, numbers:write, operations:read, prices:read, recordings:read, recordings:write, settings:read, settings:write, subaccounts:manage, tags:read, tags:write, team:manage, team:read, variables:read, variables:write, webhooks:manage, webhooks:receive, workflows:read, workflows:write